<template>
	<view class="FollwMe-list-items">
		<view class="list-item">
			<view class="list-item-image">
				<image src="https://web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" mode=""></image>
			</view>
			<view class="list-item-info">
				<view class="list-item-nickname">好好先生</view>
				<view class="list-item-time-Online">
					<view class="list-item-time">
						4分钟前活跃
					</view>
					<view class="list-item-Online">
						被他或她<text>{{concernDate('2023-5-18 09:20')}}</text>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		computed
	} from 'vue'
	let concernDate = computed(() => {
		return time => {
			// console.log(time);
			let ptime = new Date(time).getTime()
			const twentyFourHours = 24 * 60 * 60 * 1000
			const fortyEightHours = 24 * 60 * 60 * 1000 * 2;
			const date = new Date()
			const year = date.getFullYear();
			const month = date.getMonth() + 1;
			const day = date.getDate();
			const today = `${year}-${month}-${day}`;
			const todayTime = new Date(today).getTime();
			const yesterdayTime = new Date(todayTime - twentyFourHours).getTime();
			const lastYesterdayTime = new Date(todayTime - fortyEightHours).getTime();
			if (ptime >= todayTime) {
				
				return '关注于 ' + time.split(' ')[1];
			} else if (ptime < todayTime && yesterdayTime <= ptime) {

				return '关注于 昨天 ' + time.split(' ')[1];
			} else if (ptime < yesterdayTime && lastYesterdayTime <= ptime) {
				return '关注于 前天 ' + time.split(' ')[1];
			} else {

				return '关注于 ' + time;
			}
			return time
		}
	})
</script>

<style lang="less">
	.FollwMe-list-items {
		.list-item {
			display: flex;
			padding: 10px 15px;

			.list-item-image {
				width: 45px;
				height: 45px;

				image {
					height: 100%;
					width: 100%;
					border-radius: 100%;
				}
			}

			.list-item-info {
				margin-left: 10px;

				.list-item-nickname {
					font-weight: 700;
					font-size: 13px;
				}

				.list-item-time-Online {
					margin-top: 5px;
					display: flex;
					font-size: 14px;
					font-weight: 300;

					.list-item-time {
						width: 100px;
					}
				}
			}

		}
	}
</style>